package com.hand.wfive.loginAndVip.ui;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import com.hand.wfive.R;
import com.hand.wfive.loginAndVip.UserManager;

public class VipDialog extends Dialog {

    public VipDialogListener vipDialogListener;

    public VipDialog(Context context, VipDialogListener listener) {
        super(context, R.style.CustomDialog);
        vipDialogListener = listener;
    }


    public static void showVipDialog(Context context, VipDialogListener listener) {
        if (UserManager.getInstance().isVip()) {
            listener.isVip();
        } else {
            new VipDialog(context, listener).show();
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_dialog_vip);
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        initEvent();
    }

    private void initEvent() {
        findViewById(R.id.buy).setOnClickListener(v -> {
            if (UserManager.getInstance().isLogin()) {
                VipCenterActivity.show( getContext());
            } else {
                LoginIndexActivity.show(getContext(), true);
            }
            dismiss();
        });
        findViewById(R.id.close).setOnClickListener(v -> dismiss());
    }

}
